#pragma once

#include <string>
#include <iostream>

using namespace std;

class CCounter {

  double ticks, tickMax;
  int Max;
  int current, currentTick;
  int percent;
  
 public:
  CCounter(int m, string s) {
    cout << s << endl;
    Init(m);
  }

  void Init(int m) {
    ticks = 2.0;
    Max = m;
    current = 0;
    currentTick = 0;
    cout << "[";
    tickMax = ((double)Max/100.0)*ticks;
  }

  void Tick() {
    currentTick++;
    if (currentTick>tickMax) {
      currentTick = 0;
      int m = (int)1.0/(tickMax - currentTick);
      if (m==0) m=1;
	for (int i=0;i<m;i++) cout << ".";
      cout.flush();
    }

    current++;
    if (current==Max)
      cout << "]" << endl;
  }

};
